<?=$this->header(true, true)?>


    <?=$this->menu("newsletters")?>


    <h1><?=$this->message("label.header", _Newsletter::BUNDLE)?></h1>


    <? /* Breadcrums route */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.header", _Newsletter::BUNDLE),
                "href"=>"newsletter/list"
            ),
            array(
                "name"=>($this->newsletterForm->getNewsletter()->getNewsletterId() > 0 ?
                    $this->message("route.edit", _Core::BUNDLE) . " " .
                        "\"".$this->newsletterForm->getNewsletter()->getSubject()."\" " :
                    $this->message("route.new", _Core::BUNDLE) . " " . $this->message("label.item", _Newsletter::BUNDLE))
            )
        )
    )?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Newsletter::BUNDLE)?>


    <form id="<?=get_class($this->newsletterForm)?>" action="newsletter/save" method="post">

        <div>
            <input type="hidden"
                   name="newsletter->newsletterId"
                   value="<?=$this->newsletterForm->getNewsletter()->getNewsletterId()?>" />
        </div>

        <fieldset>

            <legend><?=$this->message("label.required", _Core::BUNDLE)?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <? if(!$this->newsletterForm->getNewsletter()->getNewsletterId() > 0): ?>
                <tr class="ctrl<?=$this->error("template")?>">
                    <th><label for="template"><?=$this->message("prompt.template", _Newsletter::BUNDLE)?></label></th>
                    <th class="required"><em>*</em></th>
                    <td>
                        <select name="template" id="template" onchange="this.form.action='newsletter/template'; this.form.submit();">
                            <option value="newsletter"<?=$this->newsletterForm->getTemplate() == "newsletter" ? " selected=\"selected\"" : ""?>>Newsletter</option>
                            <option value="newsflash"<?=$this->newsletterForm->getTemplate() == "newsflash" ? " selected=\"selected\"" : ""?>>Newsflash</option>
                        </select>
                    </td>
                </tr>
            <? endif; ?>
            <tr class="ctrl<?=$this->error("newsletter->subject")?>">
                <th><label for="newsletter_subject"><?=$this->message("prompt.subject", _Newsletter::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="newsletter->subject"
                           id="newsletter_subject"
                           value="<?=$this->newsletterForm->getNewsletter()->getSubject()?>"
                           maxlength="155"
                           type="text"
                           style="width:<?=$this->param(_Newsletter::WIDTH)?>"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("newsletter->body")?>">
                <th><label for="newsletter_body"><?=$this->message("prompt.body", _Newsletter::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <textarea name="newsletter->body"
                              id="newsletter_body"
                              rows="40" cols="70" style="width:<?=$this->param(_Newsletter::WIDTH)?>"
                              mce_editable="true"><?=$this->newsletterForm->getNewsletter()->getBody()?></textarea>
                    <p class="hint"><?=$this->message("note.image", _Newsletter::BUNDLE, null, null, false)?></p>
                </td>
            </tr>
            </table>

        </fieldset>

        <fieldset>

            <legend><?=$this->message("label.optional", _Core::BUNDLE)?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("email")?>">
                <th><label for="email"><?=$this->message("prompt.email", _Newsletter::BUNDLE)?></label></th>
                <th class="required"><em></em></th>
                <td>
                    <input name="email"
                           id="email"
                           value="<?=$this->newsletterForm->getEmail()?>"
                           maxlength="255"
                           type="text"
                           class="textInput" />
                    <p class="hint"><?=$this->message("note.email", _Newsletter::BUNDLE)?></p>
                </td>
            </tr>
            </table>

        </fieldset>

            <div class="buttons">

            <input type="button"
                   onclick="to('newsletter/list')"
                   value="<?=$this->message("button.cancel", _Core::BUNDLE)?>"
                   class="button" />
            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>

    </form>

<?=$this->footer()?>